package com.hfkz.project.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1953217872738198004L;

	@Override  
    public String intercept(ActionInvocation invocation) throws Exception {  
   		HttpServletRequest request= (HttpServletRequest) invocation.getInvocationContext().get(StrutsStatics.HTTP_REQUEST);
   		System.out.println(invocation.getInvocationContext().getName());
   		if(request.getSession().getAttribute("username")==null){
   			// session失效,重新登陆
   			return "sessionOut";
   		}else{
   		    return invocation.invoke();
   		}
   		
    }  
}
